DrawPaletteMapImage
DrawPaletteMapImage ImageIndex, Width, Height, [PalettePointer=0]
 
Parameters:

    ImageIndex = Index of the image you wish to draw
    Width = Width of image in pixels
    Height = Height of image in pixels
    [PalettePointer=0] = Optional Address (Pointer) Palette of palette. Otherwise defaults to SetPalette()i
Returns: NONE
 

     The DrawPaletteMapImage command renders a previously created palette mapped image to normal RGB image such as the screen. The drawing process can either use a user define colour palette, or the previously defined palette that was set using SetPalette. DrawPaletteMapImage can render the pixels onto any regular RGB pixel screen mode. The drawing process uses the DrawPaletteMappedStrip16 function to actually render it behind the scenes.




FACTS:


      * Palette mapping can be used to create a number of effects from shadows, raster bars, glenz vectors, water/rain animations etc etc. It's really just up to the creativity of the programmer.




Example #1: Palette Map Sprite Scene example




 
Example Source: Download This Example
  // Include the palette Mapping library
  #Include "PaletteMapping"
  
  
  // -----------------------------------------------------------------
  // -----------------------------------------------------------------
  // Set Up Palette >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  // -----------------------------------------------------------------
  // -----------------------------------------------------------------
  
  // Define a palette big enough to hold 2^16 colours
  Dim Palette($10000)
  
  // Give palette mapping library address of the palette
  // we're using.
  SetPalette(Palette())
  
  // Set Colour Index zero to rgb(0,0,0) BLACK
  Palette(0)     = RGB(0,0,0)
  
  // Set Colour as out 2 as
  Palette(1)     = RGB(30,40,50)
  
  // This number of colours currently in our palette
  ColourCount=2
  
  // Load the Ship image from the media folder to folders down
  ShipImage=LoadNewImage(ProgramDir$()+"Help/Commands/Media/ship.bmp")
  
  
  CenterText 250,80,"ORIGINAL RGB IMAGE"
  DrawImage ShipImage,200,100,false3
  
  // Convert the images normally RGB formated pixels into our
  // current palette
  ColourCount=PaletteMapRGBImage(ShipImage,Palette(), ColourCount)
  CenterText 600,80,"Palette Mapped IMAGE"
  CenterText 600,170,"Colour Count:"+Str$(ColourCount)
  
  DrawImage ShipImage,550,100,false
  
  
  
  Sync
  Wait 1000
  Wait 1000
  
  
  // -----------------------------------------------------------------
  // -----------------------------------------------------------------
  // Create a PB image we'll be using as the Palette Mapped Display
  // -----------------------------------------------------------------
  // -----------------------------------------------------------------
  Screen=NewPaletteMapImage(GetScreenWidth(),GetScreenHeight())
  
  
  Dim BackupPalette($10000)
  CopyArray Palette(),BackUpPalette()
  
  // Limit the program to 75 frames per second or less
  SetFPS 75
  
  
  Do
     
     // direct all Pb rendering to out screen image
     RenderToImage Screen
     
     
     // Fill The Screen with colour index 1.
     // CLS doesn't understand palette mapping, so we have to
     // convert our colur index into RGB form for drawing to
     // the screen
     Cls IndexToRgb(1)
     
     
     // draw our grid of ship images to the screen at the mouses
     // position
     GridImage ShipImage,MouseX(),MouseY(),10,10,true
     
     
     // Draw a rotated version of the palette mapped ship image
     DrawRotatedImage ShipImage,400,300,FadeAngle#,1,1,0,0,true
     
     
     // render our palette mapped screen to the actual screen
     RenderToScreen
     DrawPaletteMapImage(Screen,0,0)
     
     // --------------------------------------
     // Fade palette in and out
     // --------------------------------------
     ScaleLevel=128+Cos(Fadeangle#)*128
     ScaleLevel=ClipRange(ScaleLevel,0,255)
     ShadeRGB=RGB(ScaleLevel,ScaleLevel,ScaleLevel)
     
     For lp =1 To ColourCount
        Palette(lp)=RgbAlphaMult(BackupPalette(lp),ShadeRGB)
     Next
     
     Fadeangle#=WrapAngle(Fadeangle#+1)
     
     
     // show everything to the user
     Sync
  Loop EscKey()=true
  
  
  
  
 
Related Info: CreateFxImageEx | DeleteIMage | DrawPaletteMappedStrip16 | IndexToRGB | PaletteMapRGBImage :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com